<template>
	<view class="custom_model_mask">
		<view class="content_box">
			<view class="title">{{options.title}}</view>
			<view class="content">
				<text>{{options.content}}</text>
			</view>
			<view class="opt_btn_box">
				<view class="cancel_btn" :style="{'color':options.cancelColor}" v-if="options.showCancel"
					@click.stop="onClick({confirm:false,cancel:true})">{{options.cancelText}}</view>
				<view class="confirm_btn" :style="{'color':options.confirmColor}"
					@click.stop="onClick({confirm:true,cancel:false})">{{options.confirmText}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				options: {},
				title: title || '提示', //提示标题
				content: content || '确定执行此操作？', // 提示内容
				showCancel: showCancel || true, // 是否显示取消按钮
				cancelText: cancelText || '取消', // 取消按钮文本
				confirmText: confirmText || '确定', // 确认按钮文本
				cancelColor: '#000', // 取消按钮颜色(一般不做修改)
				confirmColor: '#000', // 确认按钮颜色（一般不做修改）
			}
		},
		beforeDestroy() {
			console.log('全局弹窗页面 销毁了对象')
			uni.$off('cust_model');
		},
		onLoad(option) {
			this.options = JSON.parse(decodeURIComponent(option.item));
		},
		methods: {
			onClick(result) {
				uni.$emit('cust_model', result);
				// #ifdef APP-NVUE
				e.stopPropagation()
				// #endif
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: transparent;
	}

	.custom_model_mask {
		position: fixed;
		left: 0;
		top: 0;
		right: 0;
		bottom: 0;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		justify-content: center;
		align-items: center;
		background-color: rgba(0, 0, 0, 0.5);


		.content_box {
			width: 75%;
			margin-top: 30%;
			background-color: #FFF;
			border-radius: 20rpx;
			padding-top: 20px;

			.title {
				text-align: center;
				font-size: 32rpx;
				color: #191919;
				font-weight: 400;
			}

			.content {
				height: 220rpx;
				width: 500rpx;
				border-bottom: 2rpx solid #f0f0f0;
				text-align: center;
				color: #999;
				padding: 20rpx;
				min-height: 80rpx;
				line-height: 1.4;
				color: #999;
				max-height: 22rpx;
			}

			.opt_btn_box {
				display: flex;
				flex-direction: row;
				height: 90rpx;
				line-height: 90rpx;

				.confirm_btn,
				.cancel_btn {
					flex: 1;
					text-align: center;
				}

				.cancel_btn {
					border-right: 2rpx solid #f0f0f0;
				}

			}
		}

	}
</style>